import matplotlib.pyplot as plt
from utilities import Point, Segment, flecha
from random import random
from lsi import lsi
from time import time

n = 500
x1, x2 = (-100, 100)
dx = x2 - x1
y1, y2 = (-100, 100)
dy = y2 - y1

P = [Point(x1+dx*random(), y1+dy*random()) for i in range(2*n)]
S = [Segment(P[i], P[i+1]) for i in range(0, len(P), 2)]
start = time()
I = lsi(S)
end = time()
print("Time: %f" % (end-start))

#for i in range(0, len(puntos), 2):
#    for j in range(i+2, len(puntos), 2):
#        intersecan, p = line_line_intersection(puntos[i], puntos[i+1], puntos[j], puntos[j+1])
#        if intersecan:
#            intersecciones.append(p)

#for i in range(0, len(P), 2):
#    flecha(P[i], P[i+1])

#for pi in I:
#    plt.plot(pi.x, pi.y, 'ro')

#plt.xlim(x1-0.1*dx, x2+0.1*dx)
#plt.ylim(y1-0.1*dy, y2+0.1*dy)

#plt.show()
